﻿using System;

namespace SBPweb.Communication.Shared.Library.Contacts
{

    public class ContactPresenceStateBase : PresenceStateBase
    {

        #region Constructor logic

        public ContactPresenceStateBase(AvailabilityTypes availability, string statusMessage)
            : base(statusMessage)
        {
            this.Availability = availability;
        }

        public ContactPresenceStateBase(string statusMessage)
            : this(AvailabilityTypes.None, statusMessage)
        {
        }

        #endregion

        #region Property accessors

        public AvailabilityTypes Availability
        {
            get;
            set;
        }

        #endregion

        #region Methods

        public override bool Equals(object obj)
        {
            ContactPresenceStateBase cpsb = obj as ContactPresenceStateBase;
            if (obj == null)
            {
                return false;
            }
            return Availability.Equals(cpsb.Availability);
        }

        public override string ToString()
        {
            if (string.IsNullOrEmpty(StatusMessage))
            {
                return Availability.ToString();
            }
            return string.Format("{0} - {1}", Availability.ToString(), StatusMessage);
        }

        #endregion

    }

}